package cms.common.exception;

public class BaseException extends RuntimeException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4251956796619904383L;
	
	/** 异常代码 */
	protected int code;
	
	/** 异常信息 */
	protected String msg;
	
	/** 异常原因 */
	private Throwable cause;

	protected Object data;

	public BaseException() {
		super();
	}

	public BaseException(String msg) {
		super(msg);
		this.msg = msg;
	}
	
	public BaseException(Throwable cause) {
		super(cause);
		this.cause = cause;
	}
	
	public BaseException(String msg, Throwable cause) {
		super(msg, cause);
		this.msg = msg;
		this.cause = cause;
	}

	public BaseException(int code, String msg) {
		super(msg);
		this.code = code;
		this.msg = msg;
	}

	public BaseException(int code, String msg, Throwable cause) {
		super(msg, cause);
		this.code = code;
		this.msg = msg;
		this.cause = cause;
	}
	
	public int getCode() {
		return code;
	}

	public String getMsg() {
		return msg;
	}

	public Object getData() {
		return data;
	}

	public BaseException setData(Object data) {
		this.data = data;
		return this;
	}

	public Throwable getCause() {
		return (this.cause == this ? null : this.cause);
	}

}

